<%-- 
    Document   : latest-news
    Created on : 09-Jan-2013, 14:37:45
    Author     : Roald
--%>
<%@page import="nl.hva.web.mvcwebapp.models.News"%>
<%@page import="nl.hva.web.mvcwebapp.doa.NewsDAO"%>
<%@page import="java.util.List;"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%
    List<News> newslist = NewsDAO.getNewsMax(3);
    request.setAttribute("latestNews", newslist);
%>
<c:catch var="catchNews">
    <div class="latest-news">
        <ul>
            <c:choose>
                <c:when test="${latestNews.size() != null}">

                    <c:forEach var="newsItem" items="${requestScope.latestNews}">
                        <li>
                            <a href="news/view?newsid=${newsItem.newsid}"><h3>${newsItem.newstitle}</h3></a>
                            Published at: ${newsItem.newsdate}
                        </li>         
                    </c:forEach>
                </c:when>
                <c:otherwise>
                    There are no news items.
                </c:otherwise>
            </c:choose>
        </c:catch>
        <c:if test="${catchNews != null}">
            There was an error catching the news Feed!
        </c:if>
</ul>
<br class="clearfix"/>
</div>